import { Utils } from '../utils/utils';
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'cmCurrency'
})
export class CurrencyPipe implements PipeTransform {

  transform(value: any, args?: any): any {
    if (Utils.isNumber(value)) {
            value = value / 100;
            return Utils.decimal(value, 2).toFixed(2) || 0.00;
        } else {
            const a = parseInt(value, 10);
            if (isNaN(a)) {
                return 0;
            } else {
                value = value / 100;
                return Utils.decimal(value, 2).toFixed(2) || 0.00;
            }
        }
  }

}
